package com.woniu.controller;

import com.woniu.entity.Result;
import com.woniu.service.IUserTrainingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaosong
 * @since 2023-04-01
 */
@RestController
@RequestMapping("/userTraining")
@Api(tags = "用户靶场管理")
public class UserTrainingController extends BaseController{

    @Autowired
    private IUserTrainingService userTrainingService;


//    看完解析后，修改分数
    @ApiOperation("看完解析修改")
    @GetMapping("/updateScore/{userId}/{trainingId}")
    public Result updateScore(@PathVariable Integer userId ,@PathVariable Integer trainingId){

        Boolean flag = userTrainingService.updateScore(userId,trainingId);
        return toDataResult(flag);
    }

//    用户过关修改得分
     @ApiOperation("通关得分")
     @GetMapping("/updateScore/{flag}/{userId}/{trainingId}")
     public Result updateFlag(
             @PathVariable String flag,
             @PathVariable Integer userId,
             @PathVariable Integer trainingId
     ){
          Boolean b =   userTrainingService.updateFlag(flag,userId,trainingId);
          return toDataResult(b);
     }


//   用户点击启动环境，创建一个靶场使用记录和一个用户使用靶场jilu
      @ApiOperation("启动靶场，创建记录")
      @GetMapping("/create/{userId}/{trainingId}")
      public Result createTrainingInfo(
              @PathVariable Integer userId,
              @PathVariable Integer trainingId){
        Boolean flag = userTrainingService.createTrainingInfo(userId,trainingId);

        return toDataResult(flag);
      }



}
